package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;


    @Override
    public List<User> selectAll() {

        return userDao.selectAll();
    }

    @Override
    public User selectById(int id) {

        if(id==1){
            throw new RuntimeException();
        }

       return userDao.selectById(id);
    }

    @Override
    public boolean add(User user) {

      return   userDao.add(user)>0;

    }

    @Override
    public boolean update(User user) {

     return   userDao.update(user)>0;

    }

    @Override
    public boolean deleteById(int id) {
      return  userDao.deleteById(id)>0;

    }
}
